<!--编辑栏目-->
<div class="dialog_content">
	<form id="info_form" action="{:url('editDo')}" method="post">
	<table width="100%" class="table_form">
        <tr>
            <th>标题 :</th>
            <td><input type="text" name="title" id="title" class="input-text" value="{$info.title}" size="30"></td>
        </tr>
        <tr>
            <th>缩略图 :</th>
            <td>
                <input type="text" name="img" id="J_img" class="input-text fl mr10" value="{$info.img}" size="40">
                <div id="J_upload_img" class="upload_btn" onclick="ajaxUpload('J_upload_img','J_img');"><span>上传</span></div>
                <p id="pic_box">
                {notempty name='info["img"]' id='vo'}
                <img src="{$info.img}" alt="" width="100">
                {/notempty}
                </p>
            </td>
        </tr>
	    <tr>
			<th>状态 :</th>
			<td>
				<label><input type="radio" name="status" value="1" {if condition="$info.status eq 1"}checked{/if} > 启用</label>&nbsp;&nbsp;
				<label><input type="radio" name="status" value="0" {if condition="$info.status eq 0"}checked{/if} > 禁用</label>
			</td>
		</tr>
        <tr>
            <th></th>
            <td>提示：如果推荐位调用的图片有变形，请在这里重新上传适合尺寸的图片。</td>
        </tr>
	</table>
	<input type="hidden" name="id" value="{$info.id}" />
	</form>
</div>
<script src="__PUBLIC__/js/plugins/fileuploader.js"></script>
<script>
    $(function(){
        $.formValidator.initConfig({formid:"info_form",autotip:true});
        $("#title").formValidator({onshow:'填写标题',onfocus:'填写标题'}).inputValidator({min:1,onerror:'填写标题'}).defaultPassed();

        $('#info_form').ajaxForm({success:complate,dataType:'json'});
        function complate(result){
            if(result.status == 1){
                $.dialog.get(result.dialog).close();
                $.yingloujie.tip({content:result.msg});
                setTimeout(function(){window.location.reload();},1000);
            } else {
                $.yingloujie.tip({content:result.msg, icon:'alert'});
            }
        }
    });
    function ajaxUpload(btn,input){
        //上传图片

        var img_uploader = new qq.FileUploaderBasic({
            allowedExtensions: ['jpg','gif','jpeg','png','swf'],
            button: document.getElementById(btn),
            multiple: false,
            action: "{:url('ajaxUploadImg')}",
            inputName: 'img',
            forceMultipart: true, //用$_FILES

            showMessage: function(message){
                $.yingloujie.tip({content:message, icon:'error'});
            },
            onSubmit: function(id, fileName){
                $('#'+btn).addClass('btn_disabled').find('span').text('上传中，请稍候...');
            },
            onComplete: function(id, fileName, result){
                $('#'+btn).removeClass('btn_disabled').find('span').text('上传');
                if(result.status == '1'){
                    $('#'+input).val(result.data);
                    $("#pic_box").html("<img src='"+result.data+"' width='100' />");
                } else {
                    $.yingloujie.tip({content:result.msg, icon:'error'});
                }
            }
        });
    }
</script>